package com.blackitheima2.polymorphic.test1;

public class TestCatAndAni {
    public static void main(String[] args) {
        //创建猫类对象
        Cat c=new Cat();
        c.eat();

        //多态
        Animal a=new Cat();
        a.eat();

    }
}
//父类
class Animal{
    public  void eat(){
        System.out.println("动物吃饭!");
    }
}
//子类
class Cat extends Animal{
    @Override
    public void eat() {
        System.out.println("猫吃鱼!");
    }
}
